using System;
using System.Reflection;
using UnityEngine;
using UnityEngine.Events;
#if UNITY_EDITOR
using UnityEditor.Events;
#endif
[Serializable]
public class EffectEvent : UnityEvent<Entity,Effect>, IFunctionEvent{
    
    public void Add(MethodInfo method){
        #if UNITY_EDITOR
        UnityEventTools.AddPersistentListener(
            this,
            Delegate.CreateDelegate(typeof(UnityAction<Entity,Effect>), method) as UnityAction<Entity,Effect>
        );
        #endif
    }
    
}
public class EffectFunction : MonoBehaviour
{
    public static void EffectSample(Entity target, Effect effect){
        /*Effect e = GetResources<ScriptableObject>("Effects/Sample") as Effect;
        Debug.Log("Prefab Time" + e.maxTime.value);
        Debug.Log("Effect Time" + effect.maxTime.value);*/
    }
    public static void EffectAddAttackSample(Entity target, Effect effect){
        //给作用实体的基础属性的攻击力属性添加一个影响，增加arg0的攻击力
        target.baseAttribute.attack.AddAffect(0, "SampleAttackUp", effect.args[0]);
    }
    public static void EffectRemoveAttackUpSample(Entity target, Effect effect){
        //移除实体上的SampleAttackUp影响
        target.baseAttribute.attack.RemoveAffect(0,"SampleAttackUp");
    }
}
